<?php $this->load->view('inc/header'); ?>
<!--content1-->

<div class="grid_12" style="background-color:#CCCCCC;">
  <!--เมนูข้าง-->
  <!--เมนูข้าง-->
  <div class="grid_4 alpha" style="margin-top:10px;">
  <?php
//check staff in group.
$this->db->where('member_id',$this->session->userdata('member_id'));
$check_staff = $this->db->get('staff_of_organization');
$nn_staff = $check_staff->num_rows();
?>

<?php if(($this->session->userdata('is_logged_in') == true && $nn_staff>0) || $this->session->userdata('access_level')==1)
{
?>
    <div id="side-panel-top">
      <div style="padding-left: 22px; padding-top: 11px; font-weight: bold;   color:#009933; text-shadow: 1px 1px 1px rgb(255, 255, 255);">Organization Tool's</div>
    </div>
    <div id="side-panel-middle" style="padding-left: 22px;">
      <ul  style="list-style:none;">
        <li><img src="<?=base_url()?>images/graphic/desktop.png"/> <a href="<?=base_url()?>organization/add_news">Add news</a></li>
        <li><img src="<?=base_url()?>images/graphic/find.png"/> <a href="<?=base_url()?>organization/search_news">Search news</a></li>
        <li></li>
        <img src="<?=base_url()?>images/graphic/lock.png"/> <a href="<?=base_url()?>logout">Logout</a>
      </ul>
    </div>
    <div id="side-panel-bottom"></div>
<?php } ?>
    <div class="grid_4 alpha" style="margin-top:5px;">
      <div id="side-panel-top">
        <div style="padding-left: 22px; padding-top: 11px; font-weight: bold;   color:#FF9933; text-shadow: 1px 1px 1px rgb(255, 255, 255);">Lastest News <img src="<?=base_url()?>images/graphic/rss.png"/></div>
      </div>
      <div id="side-panel-middle" style="padding-left: 22px;">
        <ul  style="list-style:none;">
          <?php 
$this->db->limit(5);
$this->db->order_by("c_org_id","desc");
$query2 = $this->db->get('content_of_organization');
foreach($query2->result() as $rows2)
{
	?>
          <li><img src="<?=base_url()?>images/arrow_bullet.gif"/>&nbsp;<a href="<?=base_url()?>organization/view_details/<?=$rows2->c_org_id?>"><?=$rows2->c_org_title?>
            </a></li>
          <?php    
}
?>
        </ul>
      </div>
      <div id="side-panel-bottom"></div>
    </div>
    <!--Left Search-->
    <!--
<div class="grid_4 alpha" style="margin-top:8px;">
<div id="side-panel-top">
<div style="padding-left: 22px; padding-top: 11px; font-weight: bold;   color:#FF9933; text-shadow: 1px 1px 1px rgb(255, 255, 255);">Search</div>
</div>
<div id="side-panel-middle" style="padding-left: 22px;"> dsf</div>
<div id="side-panel-bottom"></div>
</div> -->
    <!--close left search-->
    <!--เมนูข้าง-->
    <div class="grid_4 alpha" style="margin-top:8px;">
      <div id="side-panel-top">
        <div style="padding-left: 22px; padding-top: 11px; font-weight: bold;   color:#FF9933; text-shadow: 1px 1px 1px rgb(255, 255, 255);">Organization Category</div>
      </div>
      <div id="side-panel-middle" style="padding-left: 15px;">
        <ul id="browser" class="filetree">
          <?php
$query1 = $this->db->get('organization');
foreach($query1->result() as $rows1)
{
	$org_id = $rows1->org_id;
	$org_name = $rows1->org_name;
	?>
          <li class="closed"><img src="<?=base_url()?>images/building.png" /> <span><?php echo $org_name; ?></span>
            <ul>
              <li>&nbsp;<img src="<?=base_url()?>images/graphic/link.png" /><span> <a href="<?=base_url()?>organization/category/<?=$org_name?>/<?=$org_id?>">Link</a></span></li>
              <li>&nbsp;<img src="<?=base_url()?>images/graphic/feed.png" /><span> Rss/Feed</span></li>
              <li>&nbsp;<img src="<?=base_url()?>images/graphic/folder.png" /><span> Files</span></li>
              <li>&nbsp;<img src="<?=base_url()?>images/graphic/tags-label.png" /><span> Tag</span></li>
              <li>&nbsp;<img src="<?=base_url()?>images/graphic/user_business.png" /><span> Contact Staff</span></li>
              <li>&nbsp;<img src="<?=base_url()?>images/graphic/world.png" /><span> Website</span></li>
            </ul>
          </li>
          <?php
}
?>
        </ul>
      </div>
      <div id="side-panel-bottom"></div>
    </div>
    <!--ปิดเมนูข้าง-->
    <!--เมนูข้าง-->
    <div class="grid_4 alpha" style="margin-top:8px;">
      <div id="side-panel-top">
        <div style="padding-left: 22px; padding-top: 11px; font-weight: bold;   color:#FF9933; text-shadow: 1px 1px 1px rgb(255, 255, 255);">Statistics</div>
      </div>
      <div id="side-panel-middle" style="padding-left: 22px;">
        <ul  style="list-style:none;">
          <li><img src="<?=base_url()?>images/graphic/node-insert-next.png"/>&nbsp;Organization: <?php echo $this->db->count_all_results('organization'); ?></li>
          <li><img src="<?=base_url()?>images/graphic/newspaper.png"/>&nbsp;News: <?php echo $this->db->count_all_results('content_of_organization'); ?></li>
        </ul>
      </div>
      <div id="side-panel-bottom"></div>
    </div>
    <!--ปิดเมนูข้าง-->
  </div>
  <!--ปิดเมนูข้าง-->
  <!-- content div -->
  <div style="position:relative; height:40px;">
  <div id="pagination" style="position:absolute; left:325px; top:20px;"><?=$paginator?></div>
  </div>
<?php
foreach($query->result() as $rows)
{
	$c_org_id = $rows->c_org_id;
	$c_org_title = $rows->c_org_title;
	$c_org_content = $rows->c_org_content;
	$c_org_date = $rows->c_org_date;
	//$org_id = $rows->org_id;
	//$member_id = $rows->member_id;
	$firstname = $rows->firstname;
	$lastname = $rows->lastname;
	$org_name = $rows->org_name;
?>
  <div class="grid_8 omega" style="margin-top:10px;">
    <div id="km-topic">
      <div style="padding-left: 16px; padding-top: 11px; font-weight: bold;">
        <a href="<?=base_url()?>organization/view_details/<?=$rows->c_org_id?>"><?=$c_org_title?></a>
        <!-- admin management -->
          <?php
		  //check pair organization tb
		  $query = $this->db->get('organization');
		  foreach($query->result() as $rows){
		  	$staff_id = $rows->staff_id;
		  }
		  
			if(($this->session->userdata('is_logged_in') == true && $nn_staff>0) || $this->session->userdata('access_level')==1){
		  ?>
          <span id="admin-tools"><a href="<?=base_url()?>organization/edit/org_news/<?=$c_org_id?>"><img src="<?=base_url()?>images/graphic/pencil.png"/></a><a href="<?=base_url()?>organization/delete/org_news/<?=$c_org_id?>"><img src="<?=base_url()?>images/graphic/eraser.png"/></a></span>
          <?php
				}
		  ?>
        <!-- close admin management-->
      </div>
    </div>
    <div id="km-new-middle" style="height:auto;">
    <div id="content_text"  style="width:580px; padding-left:15px;">
      <div style="font-size:smaller; color:#666666; padding-bottom:10px;">วันที่ <?php echo $c_org_date; ?> โดย <?=$firstname?>&nbsp;<?=$lastname?></div>
      <p>
        <?php $content_html = htmlspecialchars_decode($c_org_content); echo word_limiter($content_html,20); ?>
      </p>
      <div style="padding-top:3px; font-size:smaller; color:#669933;"><img src="<?=base_url()?>images/graphic/tags-label.png"/>&nbsp;
        <?=$org_name?>
      </div>
    </div>
    </div>
    <div id="km-new-bottom"></div>
  </div>
  <?php
}
//end foreach
?> 
<style type="text/css" media="screen"> 
	#pagination a, #pagination strong {
	 background: #40B9E1;
	 padding: 4px 7px;
	 text-decoration: none;
		border: 1px solid #747474;
		color: #FFFFFF;
		font-size: 13px;
	}
	#pagination strong, #pagination a:hover {
	 font-weight: normal;
	 background: #666666;
	}		
</style>
</div>
<!--close content div-->
<div class="grid_12" style="background-color:#CCCCCC;">&nbsp;</div>
<div class="clear"></div>
<?php $this->load->view('inc/footer'); ?>
